<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    template="layout/template.xhtml">

<ui:define name="body">

    <rich:panel>
        <f:facet name="header">Teacher Details</f:facet>

        <s:decorate id="id" template="layout/display.xhtml">
            <ui:define name="label">Id</ui:define>
            <h:outputText value="#{teacherHome.instance.id}"/>
        </s:decorate>

        <s:decorate id="firstName" template="layout/display.xhtml">
            <ui:define name="label">First name</ui:define>
            <h:outputText value="#{teacherHome.instance.firstName}"/>
        </s:decorate>

        <s:decorate id="lastName" template="layout/display.xhtml">
            <ui:define name="label">Last name</ui:define>
            <h:outputText value="#{teacherHome.instance.lastName}"/>
        </s:decorate>

        <s:decorate id="passportPhotoUrl" template="layout/display.xhtml">
            <ui:define name="label">Passport photo url</ui:define>
            <h:outputText value="#{teacherHome.instance.passportPhotoUrl}"/>
        </s:decorate>

        <s:decorate id="subject" template="layout/display.xhtml">
            <ui:define name="label">Subject</ui:define>
            <h:outputText value="#{teacherHome.instance.subject}"/>
        </s:decorate>

        <s:decorate id="dateOfBirth" template="layout/display.xhtml">
            <ui:define name="label">Date of birth</ui:define>
            <h:outputText value="#{teacherHome.instance.dateOfBirth}">
                <s:convertDateTime type="date" dateStyle="short"/>
            </h:outputText>
        </s:decorate>

        <s:decorate id="qualification" template="layout/display.xhtml">
            <ui:define name="label">Qualification</ui:define>
            <h:outputText value="#{teacherHome.instance.qualification}"/>
        </s:decorate>

        <s:decorate id="mobileNumber" template="layout/display.xhtml">
            <ui:define name="label">Mobile number</ui:define>
            <h:outputText value="#{teacherHome.instance.mobileNumber}"/>
        </s:decorate>

        <s:decorate id="contactNumberInCaseOfEmergency" template="layout/display.xhtml">
            <ui:define name="label">Contact number in case of emergency</ui:define>
            <h:outputText value="#{teacherHome.instance.contactNumberInCaseOfEmergency}"/>
        </s:decorate>

        <s:decorate id="comments" template="layout/display.xhtml">
            <ui:define name="label">Comments</ui:define>
            <h:outputText value="#{teacherHome.instance.comments}"/>
        </s:decorate>

        <div style="clear:both"/>

    </rich:panel>

    <div class="actionButtons">

        <s:button view="/TeacherEdit.xhtml"
                    id="edit"
                 value="Edit"/>

        <s:button view="/#{empty teacherFrom ? 'TeacherList' : teacherFrom}.xhtml"
                    id="done"
                 value="Done"/>

    </div>

    <rich:tabPanel switchType="ajax">

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/manytoone.gif" style="vertical-align: middle; padding-right: 4px;"/>UserAccount</h:panelGroup>
        </f:facet>
    <div class="association" id="userAccountParent">

        <h:outputText value="There is no userAccount associated with this teacher."
                   rendered="#{teacherHome.instance.userAccount == null}"/>

        <rich:dataTable var="_userAccount"
                   value="#{teacherHome.instance.userAccount}"
                rendered="#{teacherHome.instance.userAccount != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="userAccountTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_userAccount.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">UserAccountname</f:facet>
                <h:outputText value="#{_userAccount.username}"/>
            </h:column>
         
            <h:column styleClass="action">
                <f:facet name="header">Action</f:facet>
                <s:link id="viewuserAccount"
                     value="View"
                      view="/UserAccount.xhtml">
                    <f:param name="userAccountId"
                           value="#{_userAccount.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </div>
    </rich:tab>

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/manytoone.gif" style="vertical-align: middle; padding-right: 4px;"/>Address by present address id</h:panelGroup>
        </f:facet>
    <div class="association" id="addressByPresentAddressIdParent">

        <h:outputText value="There is no addressByPresentAddressId associated with this teacher."
                   rendered="#{teacherHome.instance.addressByPresentAddressId == null}"/>

        <rich:dataTable var="_address"
                   value="#{teacherHome.instance.addressByPresentAddressId}"
                rendered="#{teacherHome.instance.addressByPresentAddressId != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="addressByPresentAddressIdTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_address.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Address line1</f:facet>
                <h:outputText value="#{_address.addressLine1}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Address line2</f:facet>
                <h:outputText value="#{_address.addressLine2}"/>
            </h:column>
            <h:column>
                <f:facet name="header">City</f:facet>
                <h:outputText value="#{_address.city}"/>
            </h:column>
            <h:column>
                <f:facet name="header">State</f:facet>
                <h:outputText value="#{_address.state}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Country</f:facet>
                <h:outputText value="#{_address.country}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Pin</f:facet>
                <h:outputText value="#{_address.pin}"/>
            </h:column>
            <h:column styleClass="action">
                <f:facet name="header">Action</f:facet>
                <s:link id="viewaddress"
                     value="View"
                      view="/Address.xhtml">
                    <f:param name="addressId"
                           value="#{_address.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </div>
    </rich:tab>

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/manytoone.gif" style="vertical-align: middle; padding-right: 4px;"/>Address by permanent address id</h:panelGroup>
        </f:facet>
    <div class="association" id="addressByPermanentAddressIdParent">

        <h:outputText value="There is no addressByPermanentAddressId associated with this teacher."
                   rendered="#{teacherHome.instance.addressByPermanentAddressId == null}"/>

        <rich:dataTable var="_address"
                   value="#{teacherHome.instance.addressByPermanentAddressId}"
                rendered="#{teacherHome.instance.addressByPermanentAddressId != null}"
              rowClasses="rvgRowOne,rvgRowTwo"
                      id="addressByPermanentAddressIdTable">
            <h:column>
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_address.id}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Address line1</f:facet>
                <h:outputText value="#{_address.addressLine1}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Address line2</f:facet>
                <h:outputText value="#{_address.addressLine2}"/>
            </h:column>
            <h:column>
                <f:facet name="header">City</f:facet>
                <h:outputText value="#{_address.city}"/>
            </h:column>
            <h:column>
                <f:facet name="header">State</f:facet>
                <h:outputText value="#{_address.state}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Country</f:facet>
                <h:outputText value="#{_address.country}"/>
            </h:column>
            <h:column>
                <f:facet name="header">Pin</f:facet>
                <h:outputText value="#{_address.pin}"/>
            </h:column>
            <h:column styleClass="action">
                <f:facet name="header">Action</f:facet>
                <s:link id="viewaddress"
                     value="View"
                      view="/Address.xhtml">
                    <f:param name="addressId"
                           value="#{_address.id}"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </div>
    </rich:tab>

    <rich:tab>
        <f:facet name="label">
            <h:panelGroup><h:graphicImage value="/img/onetomany.gif" style="vertical-align: middle; padding-right: 4px;"/>Courses</h:panelGroup>
        </f:facet>
    <h:form styleClass="association" id="coursesChildren">

        <h:outputText value="There are no courses associated with this teacher."
                   rendered="#{empty teacherHome.courses}"/>

        <rich:dataTable value="#{teacherHome.courses}"
                       var="_course"
                  rendered="#{not empty teacherHome.courses}"
                rowClasses="rvgRowOne,rvgRowTwo"
                        id="coursesTable">
            <rich:column sortBy="#{_course.id}">
                <f:facet name="header">Id</f:facet>
                <h:outputText value="#{_course.id}"/>
            </rich:column>
            <rich:column sortBy="#{_course.courseName}">
                <f:facet name="header">Course name</f:facet>
                <h:outputText value="#{_course.courseName}"/>
            </rich:column>
            <rich:column sortBy="#{_course.details}">
                <f:facet name="header">Details</f:facet>
                <h:outputText value="#{_course.details}"/>
            </rich:column>
            <h:column>
                <f:facet name="header">Action</f:facet>
                <s:link id="selectcourse"
                     value="Select"
                      view="/Course.xhtml">
                    <f:param name="courseId"
                            value="#{_course.id}"/>
                    <f:param name="courseFrom" value="Teacher"/>
                </s:link>
            </h:column>
        </rich:dataTable>

    </h:form>

    <div class="actionButtons">
        <s:button
               value="Add course"
                view="/CourseEdit.xhtml">
            <f:param name="teacherId"
                    value="#{teacherHome.instance.id}"/>
            <f:param name="courseFrom" value="Teacher"/>
        </s:button>
    </div>
    </rich:tab>
</rich:tabPanel>
</ui:define>

</ui:composition>
